package org.timemachine.util;

import java.io.File;

public class FileUtil {
	
	public static File getFileByProjectPath(String projectPath) throws Exception {
		
		if (projectPath == null || "".equals(projectPath)) {
			throw new Exception("Path could not be empty!!");
		}

		File file = new File(projectPath);
		if (!file.exists()) {
			throw new Exception("Path could not be found : " + projectPath);
		}
		
		if (!file.isDirectory()) {
			throw new Exception("Path should be project main directory : " + projectPath);
		}
		return file;
	}

	public static File getExistingFileByProjectPath(String projectPath) throws Exception {
		
		if (projectPath == null || "".equals(projectPath)) {
			throw new Exception("Path could not be empty!!");
		}
	
		File file = new File(projectPath);
		if (!file.exists()) {
			throw new Exception("Path could not be found : " + projectPath);
		}
		
		return file;
	}

}
